<template>
  <div class="daughter">
    <h1>Daughter</h1>
    <h2>Money:{{ money }}</h2>
    <br />
    <!-- 参数命名必须是$parent -->
    <button @click="handler($parent)">Borrow money from Dad</button>
  </div>
</template>

<script setup>
import { ref } from "vue";

// 子组件钱数
let money = ref(999);

const handler = (parent) => {
  console.log("dau", parent.money);
  money.value += 20;
  parent.money -= 20;
};
</script>
<style scoped>
.daughter {
  width: 300px;
  height: 200px;
  background-color: hotpink;
}
</style>
